#!/usr/bin/env python

import os, sys

if len(sys.argv) <> 3 :
	print 'cl_get_scaffolds.py <path to scripts> <kind_of_fragment> [all, simple]'
	sys.exit(1)

path = sys.argv[1]
frag_type = sys.argv[2]


files = os.listdir('./')


for i in files:
	if i[-4:] == '.smi':
		file_name = i[:-4] + '_start.bin'
		start_file = open(file_name, 'w')


		start_file.write("#BSUB-q short             	# Job queue\n#BSUB-o job.output              # output is sent to file job.output\n#BSUB-J test_mogon              # name of the job\n")
		start_file.write(path + '/get_scaffolds.py  ')
		start_file.write(i + ' ' + i[:-4] + '_scaff.smi ' + i[:-4] + '_failed.smi ' + frag_type)

		start_file.close()
		os.system('chmod 744 '  + file_name)
		command = 'qsub -q short ' + file_name
		print command
		os.system(command)

	
	
